package org.examSys.Dao.ImpI;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.examSys.Dao.GradeDao;
import org.examSys.entity.Grade;
import org.examSys.utils.BaseDao;

public class GradeDaoImpI extends BaseDao implements GradeDao {

	@Override
	public List<Grade> getAll() {
		String sql="SELECT * FROM Grade";
		ResultSet rs=super.executeQuery(sql);
		List<Grade> gradeslist=new ArrayList<>();
		try {
			while(rs.next()) {
				Grade g=new Grade();
				g.setId(rs.getInt("id"));
				g.setGradeName(rs.getString("GradeName"));
				gradeslist.add(g);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			try {
				super.CloseAll(rs, rs.getStatement().getConnection(), rs.getStatement());
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return gradeslist;
	}

}
